{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: tqdm in d:\\program\\anaconda\\envs\\ai\\lib\\site-packages (4.46.0)\n",
      "Requirement already satisfied: lightgbm in d:\\program\\anaconda\\envs\\ai\\lib\\site-packages (2.3.0)\n",
      "Requirement already satisfied: scipy in d:\\program\\anaconda\\envs\\ai\\lib\\site-packages (from lightgbm) (1.3.2)\n",
      "Requirement already satisfied: scikit-learn in d:\\program\\anaconda\\envs\\ai\\lib\\site-packages (from lightgbm) (0.22.1)\n",
      "Requirement already satisfied: numpy in d:\\program\\anaconda\\envs\\ai\\lib\\site-packages (from lightgbm) (1.17.4)\n",
      "Requirement already satisfied: joblib>=0.11 in d:\\program\\anaconda\\envs\\ai\\lib\\site-packages (from scikit-learn->lightgbm) (0.14.1)\n"
     ]
    }
   ],
   "source": [
    "! pip install tqdm\n",
    "! pip install lightgbm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from tqdm import tqdm\n",
    "from sklearn.metrics import mean_squared_error,explained_variance_score\n",
    "from sklearn.model_selection import KFold\n",
    "import lightgbm as lgb\n",
    "import math\n",
    "import os\n",
    "test_data_path = '../data/A_testData0531.csv'\n",
    "route_order_folder_path = '../data/route_order_data'\n",
    "port_path = '../data/port.csv'\n",
    "result_path = '../result/result_server_20200622.csv'\n",
    "\n",
    "# import moxing as mox\n",
    "# OBS_RES_PATH =  \"s3://ship-eta/result/result_server_20200622.csv\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "def format_data_type(data, mode='train'):\n",
    "    if mode=='test':\n",
    "        data['onboardDate'] = pd.to_datetime(data['onboardDate'], infer_datetime_format=True)\n",
    "        data['temp_timestamp'] = data['timestamp']\n",
    "        data['ETA'] = None\n",
    "        data['creatDate'] = None\n",
    "    data['loadingOrder'] = data['loadingOrder'].astype(str)\n",
    "    data['timestamp'] = pd.to_datetime(data['timestamp'], infer_datetime_format=True)\n",
    "    data['longitude'] = data['longitude'].astype(float)\n",
    "    data['latitude'] = data['latitude'].astype(float)\n",
    "    data['speed'] = data['speed'].astype(float)\n",
    "    data['TRANSPORT_TRACE'] = data['TRANSPORT_TRACE'].astype(str)\n",
    "    return data\n",
    "\n",
    "def get_test_data_info(path):\n",
    "    data = pd.read_csv(path) \n",
    "    test_trace_set = data['TRANSPORT_TRACE'].unique()\n",
    "    test_order_belong_to_trace = {}\n",
    "    for item in test_trace_set:\n",
    "        orders = data[data['TRANSPORT_TRACE'] == item]['loadingOrder'].unique()\n",
    "        test_order_belong_to_trace[item] = orders\n",
    "    return format_data_type(data, mode='test'), test_trace_set, test_order_belong_to_trace\n",
    "\n",
    "test_data_origin, test_trace_set, test_order_belong_to_trace = get_test_data_info(test_data_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_port_info():\n",
    "    port_data = {}\n",
    "    test_port_set = set()\n",
    "    for route in test_trace_set:\n",
    "        ports = route.split('-')\n",
    "        test_port_set = set.union(test_port_set, set(ports))\n",
    "    port_data_origin = pd.read_csv(port_path)\n",
    "    if (port_data_origin.shape[0] > 1000):\n",
    "    valid_order_name = valid_order_name[:200]\n",
    "    for item in port_data_origin.itertuples():\n",
    "        if getattr(item, 'TRANS_NODE_NAME') in test_port_set:\n",
    "            port_data[getattr(item, 'TRANS_NODE_NAME')] = {'LONGITUDE': getattr(item, 'LONGITUDE'),'LATITUDE': getattr(item, 'LATITUDE') }\n",
    "    return port_data\n",
    "port_data = get_port_info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_train_route_order_data(route):\n",
    "    route_order_data_path = os.path.join(route_order_folder_path, \"{}.csv\".format(route))\n",
    "    data = pd.read_csv(route_order_data_path, header=None, usecols = [0,2,3,4,6]\n",
    "           , names=['loadingOrder','timestamp','longitude','latitude','speed'])\n",
    "    if (data.shape[0] == 0):\n",
    "        print(\"error == \", route)\n",
    "    data['timestamp'] = pd.to_datetime(data['timestamp'], infer_datetime_format=True)\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_train_data(route_order_info, route):\n",
    "    ports = route.split(\"-\")\n",
    "    start_port = ports[0]\n",
    "    dest_port = ports[-1]\n",
    "    start_longitude = port_data[start_port]['LONGITUDE']\n",
    "    start_latitude = port_data[start_port]['LATITUDE']\n",
    "    dest_longitude = port_data[dest_port]['LONGITUDE']\n",
    "    dest_latitude = port_data[dest_port]['LATITUDE']\n",
    "    train_data = None\n",
    "    order_list = route_order_info['loadingOrder'].unique()\n",
    "    print(route, order_list.shape)\n",
    "    for order in tqdm(order_list):\n",
    "        order_info_set = route_order_info[route_order_info['loadingOrder'] == order].sort_values(by='timestamp').reset_index(drop=True)\n",
    "#         print(order_info_set)\n",
    "#       获取起航时间\n",
    "        start_time = order_info_set['timestamp'].min()\n",
    "        start_index = 0\n",
    "        for (index, info_item) in order_info_set.iterrows():\n",
    "            if abs(info_item['longitude']-start_longitude) < 0.5 and abs(info_item['latitude']-start_latitude) < 0.5 and info_item['speed'] > 0:\n",
    "                start_time = max(start_time, info_item['timestamp'])\n",
    "                start_index = index\n",
    "                break \n",
    "#       获取到达目的地时间，这里需要用 GPS 判断\n",
    "        end_time = order_info_set['timestamp'].max()\n",
    "        end_index = order_info_set.size-1\n",
    "        for (index, info_item) in order_info_set.iterrows():\n",
    "            if abs(info_item['longitude'] - dest_longitude) < 0.3 and abs(info_item['latitude'] - dest_latitude) < 0.3:\n",
    "                end_time = min(end_time, info_item['timestamp'])\n",
    "                end_index = index\n",
    "                break\n",
    "                \n",
    "#         修正起点终点逆序\n",
    "        if (end_time < start_time):\n",
    "            start_time,end_time = end_time,start_time\n",
    "            start_index,end_index = end_index,start_index\n",
    "#         print(start_index, end_index)\n",
    "#         print(order_info_set)\n",
    "#         人工截取前 40% 的数据   \n",
    "        order_info_set = order_info_set[start_index:end_index+1]\n",
    "        cut_size = math.ceil(order_info_set.shape[0]*0.4)\n",
    "        order_info_set = order_info_set[0:cut_size]\n",
    "        \n",
    "#         截取数据\n",
    "        if (order_info_set.shape[0] > 100):\n",
    "            index = np.linspace(0, order_info_set.shape[0]-1, num=100,dtype=int).tolist()\n",
    "            order_info_set = order_info_set.iloc[index]     \n",
    "#         获取经纬度速度信息\n",
    "        agg_function = ['min', 'max', 'mean', 'median']\n",
    "        agg_col = ['latitude', 'longitude', 'speed']\n",
    "        feature_temp = order_info_set.groupby('loadingOrder')[agg_col].agg(agg_function).reset_index()\n",
    "        feature_temp.columns = ['loadingOrder'] + ['{}_{}'.format(i, j) for i in agg_col for j in agg_function]\n",
    "#         算出航行用时\n",
    "        feature_temp['label'] = (end_time - start_time).total_seconds()\n",
    "        train_data = pd.concat([train_data,feature_temp])\n",
    "    print('train data size     ', train_data.shape)\n",
    "    if (train_data.shape[0] < 10):\n",
    "        for i in range(5):\n",
    "            train_data = pd.concat([train_data,train_data])\n",
    "    return train_data.reset_index(drop=True)\n",
    "\n",
    "def get_test_data(order):\n",
    "    order_info_set = test_data_origin[test_data_origin['loadingOrder'] == order].sort_values(by='timestamp')\n",
    "    agg_function = ['min', 'max', 'mean', 'median']\n",
    "    agg_col = ['latitude', 'longitude', 'speed']\n",
    "    feature = order_info_set.groupby('loadingOrder')[agg_col].agg(agg_function).reset_index()\n",
    "    feature.columns = ['loadingOrder'] + ['{}_{}'.format(i, j) for i in agg_col for j in agg_function]\n",
    "    return feature.reset_index(drop=True)\n",
    "def mse_score_eval(preds, valid):\n",
    "    labels = valid.get_label()\n",
    "    scores = mean_squared_error(y_true=labels, y_pred=preds)\n",
    "    return 'mse_score', scores, True\n",
    "def train_model(x, y, seed=981125, is_shuffle=True):\n",
    "    train_pred = np.zeros((x.shape[0], ))\n",
    "    n_splits = min(5, x.shape[0])\n",
    "    # Kfold\n",
    "    fold = KFold(n_splits=n_splits, shuffle=is_shuffle, random_state=seed)\n",
    "    kf_way = fold.split(x)\n",
    "    # params\n",
    "    params = {\n",
    "        'learning_rate': 0.01,\n",
    "        'boosting_type': 'gbdt',\n",
    "        'objective': 'regression',\n",
    "        'num_leaves': 36,\n",
    "        'feature_fraction': 0.6,\n",
    "        'bagging_fraction': 0.7,\n",
    "        'bagging_freq': 6,\n",
    "        'seed': 8,\n",
    "        'bagging_seed': 1,\n",
    "        'feature_fraction_seed': 7,\n",
    "        'min_data_in_leaf': 25,\n",
    "        'nthread': 8,\n",
    "        'verbose': 1,\n",
    "    }\n",
    "    # train\n",
    "    for n_fold, (train_idx, valid_idx) in enumerate(kf_way, start=1):\n",
    "        train_x, train_y = x.iloc[train_idx], y.iloc[train_idx]\n",
    "        valid_x, valid_y = x.iloc[valid_idx], y.iloc[valid_idx]\n",
    "        # 数据加载\n",
    "        n_train = lgb.Dataset(train_x, label=train_y)\n",
    "        n_valid = lgb.Dataset(valid_x, label=valid_y)\n",
    "        clf = lgb.train(\n",
    "            params=params,\n",
    "            train_set=n_train,\n",
    "            num_boost_round=3000,\n",
    "            valid_sets=[n_valid],\n",
    "            early_stopping_rounds=100,\n",
    "            verbose_eval=100,\n",
    "            feval=mse_score_eval\n",
    "        )\n",
    "        train_pred[valid_idx] = clf.predict(valid_x, num_iteration=clf.best_iteration)\n",
    "    return clf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  0%|          | 0/22 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "++++++++++++++++++\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "  0%|          | 0/493 [00:00<?, ?it/s]\u001b[A"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CNYTN-MXZLO (493,)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "  0%|          | 1/493 [00:01<08:26,  1.03s/it]\u001b[A\n",
      "  0%|          | 2/493 [00:02<08:18,  1.02s/it]\u001b[A\n",
      "  1%|          | 3/493 [00:03<08:49,  1.08s/it]\u001b[A\n",
      "  1%|          | 4/493 [00:04<08:43,  1.07s/it]\u001b[A\n",
      "  1%|          | 5/493 [00:05<08:34,  1.05s/it]\u001b[A\n",
      "  1%|          | 6/493 [00:06<08:31,  1.05s/it]\u001b[A\n",
      "  1%|▏         | 7/493 [00:07<08:23,  1.04s/it]\u001b[A\n",
      "  2%|▏         | 8/493 [00:08<08:10,  1.01s/it]\u001b[A\n",
      "  2%|▏         | 9/493 [00:09<08:16,  1.03s/it]\u001b[A\n",
      "  2%|▏         | 10/493 [00:10<08:24,  1.04s/it]\u001b[A\n",
      "  2%|▏         | 11/493 [00:11<08:50,  1.10s/it]\u001b[A\n",
      "  2%|▏         | 12/493 [00:12<09:04,  1.13s/it]\u001b[A\n",
      "  3%|▎         | 13/493 [00:13<08:39,  1.08s/it]\u001b[A\n",
      "  3%|▎         | 14/493 [00:14<08:22,  1.05s/it]\u001b[A\n",
      "  3%|▎         | 15/493 [00:15<08:07,  1.02s/it]\u001b[A\n",
      "  3%|▎         | 16/493 [00:16<07:56,  1.00it/s]\u001b[A\n",
      "  3%|▎         | 17/493 [00:17<07:48,  1.02it/s]\u001b[A\n",
      "  4%|▎         | 18/493 [00:18<08:18,  1.05s/it]\u001b[A\n",
      "  4%|▍         | 19/493 [00:19<08:10,  1.04s/it]\u001b[A\n",
      "  4%|▍         | 20/493 [00:20<08:05,  1.03s/it]\u001b[A\n",
      "  4%|▍         | 21/493 [00:21<07:59,  1.01s/it]\u001b[A\n",
      "  4%|▍         | 22/493 [00:22<07:51,  1.00s/it]\u001b[A\n",
      "  5%|▍         | 23/493 [00:23<07:47,  1.01it/s]\u001b[A\n",
      "  5%|▍         | 24/493 [00:24<07:46,  1.01it/s]\u001b[A\n",
      "  5%|▌         | 25/493 [00:29<16:28,  2.11s/it]\u001b[A\n",
      "  5%|▌         | 26/493 [00:30<13:50,  1.78s/it]\u001b[A\n",
      "  5%|▌         | 27/493 [00:31<11:57,  1.54s/it]\u001b[A\n",
      "  6%|▌         | 28/493 [00:32<10:37,  1.37s/it]\u001b[A\n",
      "  6%|▌         | 29/493 [00:33<09:43,  1.26s/it]\u001b[A\n",
      "  6%|▌         | 30/493 [00:34<09:03,  1.17s/it]\u001b[A\n",
      "  6%|▋         | 31/493 [00:35<08:43,  1.13s/it]\u001b[A\n",
      "  6%|▋         | 32/493 [00:36<08:16,  1.08s/it]\u001b[A\n",
      "  7%|▋         | 33/493 [00:37<08:00,  1.05s/it]\u001b[A\n",
      "  7%|▋         | 34/493 [00:38<07:57,  1.04s/it]\u001b[A\n",
      "  7%|▋         | 35/493 [00:39<07:44,  1.01s/it]\u001b[A\n",
      "  7%|▋         | 36/493 [00:40<07:33,  1.01it/s]\u001b[A\n",
      "  8%|▊         | 37/493 [00:41<07:29,  1.01it/s]\u001b[A\n",
      "  8%|▊         | 38/493 [00:42<07:23,  1.03it/s]\u001b[A\n",
      "  8%|▊         | 39/493 [00:43<07:20,  1.03it/s]\u001b[A\n",
      "  8%|▊         | 40/493 [00:44<07:22,  1.02it/s]\u001b[A\n",
      "  8%|▊         | 41/493 [00:45<07:20,  1.03it/s]\u001b[A\n",
      "  9%|▊         | 42/493 [00:46<07:18,  1.03it/s]\u001b[A\n",
      "  9%|▊         | 43/493 [00:47<07:12,  1.04it/s]\u001b[A\n",
      "  9%|▉         | 44/493 [00:50<11:54,  1.59s/it]\u001b[A\n",
      "  9%|▉         | 45/493 [00:52<12:57,  1.73s/it]\u001b[A\n",
      "  9%|▉         | 46/493 [00:57<20:17,  2.72s/it]\u001b[A\n",
      " 10%|▉         | 47/493 [00:59<18:29,  2.49s/it]\u001b[A\n",
      " 10%|▉         | 48/493 [01:00<15:02,  2.03s/it]\u001b[A\n",
      " 10%|▉         | 49/493 [01:01<12:35,  1.70s/it]\u001b[A\n",
      " 10%|█         | 50/493 [01:02<10:58,  1.49s/it]\u001b[A\n",
      " 10%|█         | 51/493 [01:03<09:45,  1.32s/it]\u001b[A\n",
      " 11%|█         | 52/493 [01:03<08:52,  1.21s/it]\u001b[A\n",
      " 11%|█         | 53/493 [01:08<15:59,  2.18s/it]\u001b[A\n",
      " 11%|█         | 54/493 [01:12<20:50,  2.85s/it]\u001b[A\n",
      " 11%|█         | 55/493 [01:17<24:01,  3.29s/it]\u001b[A\n",
      " 11%|█▏        | 56/493 [01:22<29:18,  4.02s/it]\u001b[A\n",
      " 12%|█▏        | 57/493 [01:27<31:23,  4.32s/it]\u001b[A\n",
      " 12%|█▏        | 58/493 [01:32<32:40,  4.51s/it]\u001b[A\n",
      " 12%|█▏        | 59/493 [01:37<33:37,  4.65s/it]\u001b[A\n",
      " 12%|█▏        | 60/493 [01:41<32:15,  4.47s/it]\u001b[A\n",
      " 12%|█▏        | 61/493 [01:46<31:33,  4.38s/it]\u001b[A\n",
      " 13%|█▎        | 62/493 [01:50<31:08,  4.33s/it]\u001b[A\n",
      " 13%|█▎        | 63/493 [01:54<30:38,  4.28s/it]\u001b[A\n",
      " 13%|█▎        | 64/493 [01:55<23:25,  3.28s/it]\u001b[A\n",
      " 13%|█▎        | 65/493 [01:56<18:13,  2.55s/it]\u001b[A\n",
      " 13%|█▎        | 66/493 [01:58<16:53,  2.37s/it]\u001b[A\n",
      " 14%|█▎        | 67/493 [01:59<13:37,  1.92s/it]\u001b[A\n",
      " 14%|█▍        | 68/493 [01:59<11:20,  1.60s/it]\u001b[A\n",
      " 14%|█▍        | 69/493 [02:00<09:51,  1.40s/it]\u001b[A\n",
      " 14%|█▍        | 70/493 [02:02<10:59,  1.56s/it]\u001b[A\n",
      " 14%|█▍        | 71/493 [02:04<11:47,  1.68s/it]\u001b[A\n",
      " 15%|█▍        | 72/493 [02:05<10:04,  1.44s/it]\u001b[A\n",
      " 15%|█▍        | 73/493 [02:06<08:55,  1.27s/it]\u001b[A\n",
      " 15%|█▌        | 74/493 [02:07<08:01,  1.15s/it]\u001b[A\n",
      " 15%|█▌        | 75/493 [02:08<07:31,  1.08s/it]\u001b[A\n",
      " 15%|█▌        | 76/493 [02:09<07:02,  1.01s/it]\u001b[A\n",
      " 16%|█▌        | 77/493 [02:11<09:11,  1.33s/it]\u001b[A\n",
      " 16%|█▌        | 78/493 [02:12<08:14,  1.19s/it]\u001b[A\n",
      " 16%|█▌        | 79/493 [02:12<07:33,  1.10s/it]\u001b[A\n",
      " 16%|█▌        | 80/493 [02:13<07:04,  1.03s/it]\u001b[A\n",
      " 16%|█▋        | 81/493 [02:14<06:42,  1.02it/s]\u001b[A\n",
      " 17%|█▋        | 82/493 [02:15<06:32,  1.05it/s]\u001b[A\n",
      " 17%|█▋        | 83/493 [02:16<06:21,  1.08it/s]\u001b[A\n",
      " 17%|█▋        | 84/493 [02:17<06:11,  1.10it/s]\u001b[A\n",
      " 17%|█▋        | 85/493 [02:19<08:15,  1.21s/it]\u001b[A\n",
      " 17%|█▋        | 86/493 [02:20<07:39,  1.13s/it]\u001b[A\n",
      " 18%|█▊        | 87/493 [02:21<07:36,  1.12s/it]\u001b[A\n",
      " 18%|█▊        | 88/493 [02:22<07:14,  1.07s/it]\u001b[A\n",
      " 18%|█▊        | 89/493 [02:23<07:00,  1.04s/it]\u001b[A\n",
      " 18%|█▊        | 90/493 [02:24<06:47,  1.01s/it]\u001b[A\n",
      " 18%|█▊        | 91/493 [02:25<06:40,  1.00it/s]\u001b[A\n",
      " 19%|█▊        | 92/493 [02:26<06:39,  1.00it/s]\u001b[A\n",
      " 19%|█▉        | 93/493 [02:27<06:41,  1.00s/it]\u001b[A\n",
      " 19%|█▉        | 94/493 [02:28<06:40,  1.00s/it]\u001b[A\n",
      " 19%|█▉        | 95/493 [02:29<06:41,  1.01s/it]\u001b[A\n",
      " 19%|█▉        | 96/493 [02:30<06:34,  1.01it/s]\u001b[A\n",
      " 20%|█▉        | 97/493 [02:31<06:35,  1.00it/s]\u001b[A\n",
      " 20%|█▉        | 98/493 [02:32<06:37,  1.01s/it]\u001b[A\n",
      " 20%|██        | 99/493 [02:33<06:35,  1.00s/it]\u001b[A\n",
      " 20%|██        | 100/493 [02:34<06:37,  1.01s/it]\u001b[A\n",
      " 20%|██        | 101/493 [02:35<06:33,  1.00s/it]\u001b[A\n",
      " 21%|██        | 102/493 [02:36<06:35,  1.01s/it]\u001b[A\n",
      " 21%|██        | 103/493 [02:37<06:33,  1.01s/it]\u001b[A\n",
      " 21%|██        | 104/493 [02:38<06:28,  1.00it/s]\u001b[A\n",
      " 21%|██▏       | 105/493 [02:39<06:26,  1.00it/s]\u001b[A\n",
      " 22%|██▏       | 106/493 [02:41<09:08,  1.42s/it]\u001b[A\n",
      " 22%|██▏       | 107/493 [02:42<08:27,  1.31s/it]\u001b[A\n",
      " 22%|██▏       | 108/493 [02:45<10:47,  1.68s/it]\u001b[A\n",
      " 22%|██▏       | 109/493 [02:46<09:26,  1.48s/it]\u001b[A\n",
      " 22%|██▏       | 110/493 [02:46<08:03,  1.26s/it]\u001b[A\n",
      " 23%|██▎       | 111/493 [02:47<07:03,  1.11s/it]\u001b[A\n",
      " 23%|██▎       | 112/493 [02:48<06:24,  1.01s/it]\u001b[A\n",
      " 23%|██▎       | 113/493 [02:49<06:08,  1.03it/s]\u001b[A\n",
      " 23%|██▎       | 114/493 [02:50<05:54,  1.07it/s]\u001b[A\n",
      " 23%|██▎       | 115/493 [02:50<05:36,  1.12it/s]\u001b[A\n",
      " 24%|██▎       | 116/493 [02:51<05:23,  1.17it/s]\u001b[A\n",
      " 24%|██▎       | 117/493 [02:52<05:22,  1.17it/s]\u001b[A\n",
      " 24%|██▍       | 118/493 [02:53<05:18,  1.18it/s]\u001b[A\n",
      " 24%|██▍       | 119/493 [02:54<05:15,  1.19it/s]\u001b[A\n",
      " 24%|██▍       | 120/493 [02:55<05:12,  1.19it/s]\u001b[A\n",
      " 25%|██▍       | 121/493 [02:55<05:09,  1.20it/s]\u001b[A\n",
      " 25%|██▍       | 122/493 [02:56<05:09,  1.20it/s]\u001b[A\n",
      " 25%|██▍       | 123/493 [02:57<05:08,  1.20it/s]\u001b[A\n",
      " 25%|██▌       | 124/493 [02:58<05:12,  1.18it/s]\u001b[A\n",
      " 25%|██▌       | 125/493 [02:59<05:14,  1.17it/s]\u001b[A\n",
      " 26%|██▌       | 126/493 [03:00<05:17,  1.16it/s]\u001b[A\n",
      " 26%|██▌       | 127/493 [03:01<05:22,  1.14it/s]\u001b[A\n",
      " 26%|██▌       | 128/493 [03:01<05:22,  1.13it/s]\u001b[A\n",
      " 26%|██▌       | 129/493 [03:02<05:22,  1.13it/s]\u001b[A\n",
      " 26%|██▋       | 130/493 [03:03<05:19,  1.14it/s]\u001b[A\n",
      " 27%|██▋       | 131/493 [03:04<05:17,  1.14it/s]\u001b[A\n",
      " 27%|██▋       | 132/493 [03:05<05:16,  1.14it/s]\u001b[A\n",
      " 27%|██▋       | 133/493 [03:06<05:14,  1.14it/s]\u001b[A\n",
      " 27%|██▋       | 134/493 [03:07<05:13,  1.14it/s]\u001b[A\n",
      " 27%|██▋       | 135/493 [03:08<05:18,  1.13it/s]\u001b[A\n",
      " 28%|██▊       | 136/493 [03:09<05:16,  1.13it/s]\u001b[A\n",
      " 28%|██▊       | 137/493 [03:09<05:15,  1.13it/s]\u001b[A\n",
      " 28%|██▊       | 138/493 [03:11<05:42,  1.04it/s]\u001b[A\n",
      " 28%|██▊       | 139/493 [03:12<06:03,  1.03s/it]\u001b[A\n",
      " 28%|██▊       | 140/493 [03:13<06:15,  1.06s/it]\u001b[A\n",
      " 29%|██▊       | 141/493 [03:14<06:25,  1.09s/it]\u001b[A\n",
      " 29%|██▉       | 142/493 [03:15<06:37,  1.13s/it]\u001b[A\n",
      " 29%|██▉       | 143/493 [03:16<06:37,  1.14s/it]\u001b[A\n",
      " 29%|██▉       | 144/493 [03:18<06:37,  1.14s/it]\u001b[A\n",
      " 29%|██▉       | 145/493 [03:19<06:37,  1.14s/it]\u001b[A\n",
      " 30%|██▉       | 146/493 [03:20<06:17,  1.09s/it]\u001b[A\n",
      " 30%|██▉       | 147/493 [03:21<06:01,  1.04s/it]\u001b[A\n",
      " 30%|███       | 148/493 [03:22<05:52,  1.02s/it]\u001b[A\n",
      " 30%|███       | 149/493 [03:23<05:55,  1.03s/it]\u001b[A\n",
      " 30%|███       | 150/493 [03:24<05:55,  1.04s/it]\u001b[A\n",
      " 31%|███       | 151/493 [03:25<06:00,  1.05s/it]\u001b[A\n",
      " 31%|███       | 152/493 [03:26<06:09,  1.08s/it]\u001b[A\n",
      " 31%|███       | 153/493 [03:27<06:04,  1.07s/it]\u001b[A\n",
      " 31%|███       | 154/493 [03:28<06:05,  1.08s/it]\u001b[A\n",
      " 31%|███▏      | 155/493 [03:29<06:02,  1.07s/it]\u001b[A\n",
      " 32%|███▏      | 156/493 [03:30<05:42,  1.02s/it]\u001b[A\n",
      " 32%|███▏      | 157/493 [03:31<05:30,  1.02it/s]\u001b[A\n",
      " 32%|███▏      | 158/493 [03:32<05:16,  1.06it/s]\u001b[A\n",
      " 32%|███▏      | 159/493 [03:33<05:05,  1.09it/s]\u001b[A\n",
      " 32%|███▏      | 160/493 [03:34<05:08,  1.08it/s]\u001b[A\n",
      " 33%|███▎      | 161/493 [03:36<07:17,  1.32s/it]\u001b[A\n",
      " 33%|███▎      | 162/493 [03:38<08:45,  1.59s/it]\u001b[A\n",
      " 33%|███▎      | 163/493 [03:40<08:57,  1.63s/it]\u001b[A\n",
      " 33%|███▎      | 164/493 [03:41<09:01,  1.65s/it]\u001b[A\n",
      " 33%|███▎      | 165/493 [03:42<07:55,  1.45s/it]\u001b[A\n",
      " 34%|███▎      | 166/493 [03:43<07:08,  1.31s/it]\u001b[A\n",
      " 34%|███▍      | 167/493 [03:44<06:36,  1.22s/it]\u001b[A\n",
      " 34%|███▍      | 168/493 [03:47<08:03,  1.49s/it]\u001b[A\n",
      " 34%|███▍      | 169/493 [03:49<09:04,  1.68s/it]\u001b[A\n",
      " 34%|███▍      | 170/493 [03:51<09:36,  1.79s/it]\u001b[A\n",
      " 35%|███▍      | 171/493 [03:53<09:54,  1.85s/it]\u001b[A\n",
      " 35%|███▍      | 172/493 [03:55<10:01,  1.87s/it]\u001b[A\n",
      " 35%|███▌      | 173/493 [03:57<10:04,  1.89s/it]\u001b[A\n",
      " 35%|███▌      | 174/493 [03:58<10:02,  1.89s/it]\u001b[A\n",
      " 35%|███▌      | 175/493 [04:00<09:59,  1.89s/it]\u001b[A\n",
      " 36%|███▌      | 176/493 [04:02<10:08,  1.92s/it]\u001b[A\n",
      " 36%|███▌      | 177/493 [04:04<10:05,  1.92s/it]\u001b[A\n",
      " 36%|███▌      | 178/493 [04:06<09:59,  1.90s/it]\u001b[A\n",
      " 36%|███▋      | 179/493 [04:08<09:57,  1.90s/it]\u001b[A\n",
      " 37%|███▋      | 180/493 [04:10<09:52,  1.89s/it]\u001b[A\n",
      " 37%|███▋      | 181/493 [04:11<09:15,  1.78s/it]\u001b[A\n",
      " 37%|███▋      | 182/493 [04:13<08:54,  1.72s/it]\u001b[A\n",
      " 37%|███▋      | 183/493 [04:14<08:34,  1.66s/it]\u001b[A\n",
      " 37%|███▋      | 184/493 [04:16<08:19,  1.62s/it]\u001b[A\n",
      " 38%|███▊      | 185/493 [04:17<08:07,  1.58s/it]\u001b[A\n",
      " 38%|███▊      | 186/493 [04:19<08:08,  1.59s/it]\u001b[A\n",
      " 38%|███▊      | 187/493 [04:21<08:00,  1.57s/it]\u001b[A\n",
      " 38%|███▊      | 188/493 [04:22<07:53,  1.55s/it]\u001b[A\n",
      " 38%|███▊      | 189/493 [04:23<07:32,  1.49s/it]\u001b[A\n",
      " 39%|███▊      | 190/493 [04:25<07:21,  1.46s/it]\u001b[A\n",
      " 39%|███▊      | 191/493 [04:26<07:16,  1.45s/it]\u001b[A\n",
      " 39%|███▉      | 192/493 [04:28<07:05,  1.41s/it]\u001b[A\n",
      " 39%|███▉      | 193/493 [04:29<07:01,  1.40s/it]\u001b[A\n",
      " 39%|███▉      | 194/493 [04:30<06:55,  1.39s/it]\u001b[A\n",
      " 40%|███▉      | 195/493 [04:32<07:04,  1.42s/it]\u001b[A\n",
      " 40%|███▉      | 196/493 [04:33<06:21,  1.28s/it]\u001b[A\n",
      " 40%|███▉      | 197/493 [04:34<05:50,  1.18s/it]\u001b[A\n",
      " 40%|████      | 198/493 [04:35<05:29,  1.12s/it]\u001b[A\n",
      " 40%|████      | 199/493 [04:36<05:10,  1.06s/it]\u001b[A\n",
      " 41%|████      | 200/493 [04:37<04:58,  1.02s/it]\u001b[A\n",
      " 41%|████      | 201/493 [04:37<04:48,  1.01it/s]\u001b[A\n",
      " 41%|████      | 202/493 [04:38<04:43,  1.03it/s]\u001b[A\n",
      " 41%|████      | 203/493 [04:40<05:08,  1.06s/it]\u001b[A\n",
      " 41%|████▏     | 204/493 [04:41<05:13,  1.09s/it]\u001b[A\n",
      " 42%|████▏     | 205/493 [04:42<04:59,  1.04s/it]\u001b[A\n",
      " 42%|████▏     | 206/493 [04:43<04:51,  1.01s/it]\u001b[A\n",
      " 42%|████▏     | 207/493 [04:44<04:43,  1.01it/s]\u001b[A\n",
      " 42%|████▏     | 208/493 [04:45<04:38,  1.02it/s]\u001b[A\n",
      " 42%|████▏     | 209/493 [04:46<04:34,  1.04it/s]\u001b[A\n",
      " 43%|████▎     | 210/493 [04:46<04:30,  1.05it/s]\u001b[A\n",
      " 43%|████▎     | 211/493 [04:47<04:27,  1.05it/s]\u001b[A\n",
      " 43%|████▎     | 212/493 [04:48<04:27,  1.05it/s]\u001b[A\n",
      " 43%|████▎     | 213/493 [04:49<04:21,  1.07it/s]\u001b[A\n",
      " 43%|████▎     | 214/493 [04:50<04:22,  1.06it/s]\u001b[A\n",
      " 44%|████▎     | 215/493 [04:51<04:20,  1.07it/s]\u001b[A\n",
      " 44%|████▍     | 216/493 [04:52<04:18,  1.07it/s]\u001b[A\n",
      " 44%|████▍     | 217/493 [04:53<04:17,  1.07it/s]\u001b[A\n",
      " 44%|████▍     | 218/493 [04:54<04:14,  1.08it/s]\u001b[A\n",
      " 44%|████▍     | 219/493 [04:55<04:12,  1.09it/s]\u001b[A\n",
      " 45%|████▍     | 220/493 [04:56<04:14,  1.07it/s]\u001b[A\n",
      " 45%|████▍     | 221/493 [04:57<04:12,  1.08it/s]\u001b[A\n",
      " 45%|████▌     | 222/493 [04:58<04:10,  1.08it/s]\u001b[A\n",
      " 45%|████▌     | 223/493 [04:59<04:09,  1.08it/s]\u001b[A\n",
      " 45%|████▌     | 224/493 [04:59<04:09,  1.08it/s]\u001b[A\n",
      " 46%|████▌     | 225/493 [05:00<04:11,  1.07it/s]\u001b[A\n",
      " 46%|████▌     | 226/493 [05:01<04:08,  1.07it/s]\u001b[A\n",
      " 46%|████▌     | 227/493 [05:02<04:15,  1.04it/s]\u001b[A\n",
      " 46%|████▌     | 228/493 [05:03<04:15,  1.04it/s]\u001b[A\n",
      " 46%|████▋     | 229/493 [05:04<04:13,  1.04it/s]\u001b[A\n",
      " 47%|████▋     | 230/493 [05:05<04:14,  1.03it/s]\u001b[A\n",
      " 47%|████▋     | 231/493 [05:06<04:23,  1.01s/it]\u001b[A\n",
      " 47%|████▋     | 232/493 [05:07<04:20,  1.00it/s]\u001b[A\n",
      " 47%|████▋     | 233/493 [05:08<04:15,  1.02it/s]\u001b[A\n",
      " 47%|████▋     | 234/493 [05:09<04:12,  1.03it/s]\u001b[A\n",
      " 48%|████▊     | 235/493 [05:10<04:10,  1.03it/s]\u001b[A\n",
      " 48%|████▊     | 236/493 [05:11<04:06,  1.04it/s]\u001b[A\n",
      " 48%|████▊     | 237/493 [05:12<04:07,  1.03it/s]\u001b[A\n",
      " 48%|████▊     | 238/493 [05:13<03:55,  1.08it/s]\u001b[A\n",
      " 48%|████▊     | 239/493 [05:14<03:46,  1.12it/s]\u001b[A\n",
      " 49%|████▊     | 240/493 [05:15<03:39,  1.15it/s]\u001b[A\n",
      " 49%|████▉     | 241/493 [05:16<03:45,  1.12it/s]\u001b[A\n",
      " 49%|████▉     | 242/493 [05:16<03:47,  1.10it/s]\u001b[A\n",
      " 49%|████▉     | 243/493 [05:17<03:50,  1.08it/s]\u001b[A\n",
      " 49%|████▉     | 244/493 [05:18<03:51,  1.08it/s]\u001b[A\n",
      " 50%|████▉     | 245/493 [05:19<03:50,  1.07it/s]\u001b[A\n",
      " 50%|████▉     | 246/493 [05:20<03:55,  1.05it/s]\u001b[A\n",
      " 50%|█████     | 247/493 [05:21<03:53,  1.06it/s]\u001b[A\n",
      " 50%|█████     | 248/493 [05:22<03:53,  1.05it/s]\u001b[A\n",
      " 51%|█████     | 249/493 [05:23<03:54,  1.04it/s]\u001b[A\n",
      " 51%|█████     | 250/493 [05:24<03:49,  1.06it/s]\u001b[A\n",
      " 51%|█████     | 251/493 [05:25<03:45,  1.07it/s]\u001b[A\n",
      " 51%|█████     | 252/493 [05:26<03:47,  1.06it/s]\u001b[A\n",
      " 51%|█████▏    | 253/493 [05:27<03:42,  1.08it/s]\u001b[A\n",
      " 52%|█████▏    | 254/493 [05:28<03:40,  1.08it/s]\u001b[A\n",
      " 52%|█████▏    | 255/493 [05:29<03:42,  1.07it/s]\u001b[A\n",
      " 52%|█████▏    | 256/493 [05:30<03:39,  1.08it/s]\u001b[A\n",
      " 52%|█████▏    | 257/493 [05:31<03:38,  1.08it/s]\u001b[A\n",
      " 52%|█████▏    | 258/493 [05:32<03:36,  1.08it/s]\u001b[A\n",
      " 53%|█████▎    | 259/493 [05:32<03:35,  1.09it/s]\u001b[A\n",
      " 53%|█████▎    | 260/493 [05:33<03:35,  1.08it/s]\u001b[A\n",
      " 53%|█████▎    | 261/493 [05:34<03:34,  1.08it/s]\u001b[A\n",
      " 53%|█████▎    | 262/493 [05:35<03:34,  1.08it/s]\u001b[A\n",
      " 53%|█████▎    | 263/493 [05:36<03:35,  1.07it/s]\u001b[A\n",
      " 54%|█████▎    | 264/493 [05:37<03:27,  1.10it/s]\u001b[A\n",
      " 54%|█████▍    | 265/493 [05:38<03:27,  1.10it/s]\u001b[A\n",
      " 54%|█████▍    | 266/493 [05:39<03:27,  1.10it/s]\u001b[A\n",
      " 54%|█████▍    | 267/493 [05:40<03:29,  1.08it/s]\u001b[A\n",
      " 54%|█████▍    | 268/493 [05:41<03:24,  1.10it/s]\u001b[A\n",
      " 55%|█████▍    | 269/493 [05:42<03:21,  1.11it/s]\u001b[A\n",
      " 55%|█████▍    | 270/493 [05:42<03:17,  1.13it/s]\u001b[A\n",
      " 55%|█████▍    | 271/493 [05:43<03:14,  1.14it/s]\u001b[A\n",
      " 55%|█████▌    | 272/493 [05:44<03:13,  1.14it/s]\u001b[A\n",
      " 55%|█████▌    | 273/493 [05:45<03:13,  1.14it/s]\u001b[A\n",
      " 56%|█████▌    | 274/493 [05:46<03:11,  1.14it/s]\u001b[A\n",
      " 56%|█████▌    | 275/493 [05:47<03:10,  1.15it/s]\u001b[A\n",
      " 56%|█████▌    | 276/493 [05:48<03:08,  1.15it/s]\u001b[A\n",
      " 56%|█████▌    | 277/493 [05:48<03:07,  1.15it/s]\u001b[A\n",
      " 56%|█████▋    | 278/493 [05:49<03:06,  1.15it/s]\u001b[A\n",
      " 57%|█████▋    | 279/493 [05:50<03:17,  1.08it/s]\u001b[A\n",
      " 57%|█████▋    | 280/493 [05:51<03:24,  1.04it/s]\u001b[A\n",
      " 57%|█████▋    | 281/493 [05:52<03:28,  1.02it/s]\u001b[A\n",
      " 57%|█████▋    | 282/493 [05:54<03:35,  1.02s/it]\u001b[A\n",
      " 57%|█████▋    | 283/493 [05:55<03:40,  1.05s/it]\u001b[A\n",
      " 58%|█████▊    | 284/493 [05:56<03:39,  1.05s/it]\u001b[A\n",
      " 58%|█████▊    | 285/493 [05:57<03:38,  1.05s/it]\u001b[A\n",
      " 58%|█████▊    | 286/493 [05:58<03:36,  1.05s/it]\u001b[A\n",
      " 58%|█████▊    | 287/493 [05:59<03:36,  1.05s/it]\u001b[A\n",
      " 58%|█████▊    | 288/493 [06:00<03:34,  1.05s/it]\u001b[A\n",
      " 59%|█████▊    | 289/493 [06:01<03:35,  1.06s/it]\u001b[A\n",
      " 59%|█████▉    | 290/493 [06:02<03:34,  1.06s/it]\u001b[A\n",
      " 59%|█████▉    | 291/493 [06:03<03:32,  1.05s/it]\u001b[A\n",
      " 59%|█████▉    | 292/493 [06:04<03:03,  1.10it/s]\u001b[A\n",
      " 59%|█████▉    | 293/493 [06:04<02:42,  1.23it/s]\u001b[A\n",
      " 60%|█████▉    | 294/493 [06:05<02:29,  1.34it/s]\u001b[A\n",
      " 60%|█████▉    | 295/493 [06:05<02:18,  1.43it/s]\u001b[A\n",
      " 60%|██████    | 296/493 [06:06<02:11,  1.50it/s]\u001b[A\n",
      " 60%|██████    | 297/493 [06:07<02:06,  1.55it/s]\u001b[A\n",
      " 60%|██████    | 298/493 [06:07<02:02,  1.59it/s]\u001b[A\n",
      " 61%|██████    | 299/493 [06:08<01:59,  1.62it/s]\u001b[A\n",
      " 61%|██████    | 300/493 [06:08<01:57,  1.64it/s]\u001b[A\n",
      " 61%|██████    | 301/493 [06:10<03:19,  1.04s/it]\u001b[A\n",
      " 61%|██████▏   | 302/493 [06:11<03:04,  1.03it/s]\u001b[A\n",
      " 61%|██████▏   | 303/493 [06:12<02:53,  1.09it/s]\u001b[A\n",
      " 62%|██████▏   | 304/493 [06:13<02:46,  1.14it/s]\u001b[A\n",
      " 62%|██████▏   | 305/493 [06:14<02:40,  1.17it/s]\u001b[A\n",
      " 62%|██████▏   | 306/493 [06:14<02:36,  1.20it/s]\u001b[A\n",
      " 62%|██████▏   | 307/493 [06:15<02:33,  1.22it/s]\u001b[A\n",
      " 62%|██████▏   | 308/493 [06:16<02:31,  1.22it/s]\u001b[A\n",
      " 63%|██████▎   | 309/493 [06:17<02:33,  1.20it/s]\u001b[A\n",
      " 63%|██████▎   | 310/493 [06:18<02:35,  1.18it/s]\u001b[A\n",
      " 63%|██████▎   | 311/493 [06:19<02:34,  1.18it/s]\u001b[A\n",
      " 63%|██████▎   | 312/493 [06:20<02:37,  1.15it/s]\u001b[A\n",
      " 63%|██████▎   | 313/493 [06:20<02:36,  1.15it/s]\u001b[A\n",
      " 64%|██████▎   | 314/493 [06:21<02:37,  1.14it/s]\u001b[A\n",
      " 64%|██████▍   | 315/493 [06:22<02:36,  1.14it/s]\u001b[A\n",
      " 64%|██████▍   | 316/493 [06:23<02:35,  1.14it/s]\u001b[A\n",
      " 64%|██████▍   | 317/493 [06:24<02:33,  1.15it/s]\u001b[A\n",
      " 65%|██████▍   | 318/493 [06:25<02:32,  1.15it/s]\u001b[A\n",
      " 65%|██████▍   | 319/493 [06:26<02:34,  1.12it/s]\u001b[A\n",
      " 65%|██████▍   | 320/493 [06:27<02:33,  1.13it/s]\u001b[A\n",
      " 65%|██████▌   | 321/493 [06:27<02:29,  1.15it/s]\u001b[A\n",
      " 65%|██████▌   | 322/493 [06:28<02:28,  1.15it/s]\u001b[A\n",
      " 66%|██████▌   | 323/493 [06:29<02:26,  1.16it/s]\u001b[A\n",
      " 66%|██████▌   | 324/493 [06:30<02:24,  1.17it/s]\u001b[A\n",
      " 66%|██████▌   | 325/493 [06:31<02:22,  1.18it/s]\u001b[A\n",
      " 66%|██████▌   | 326/493 [06:32<02:24,  1.15it/s]\u001b[A\n",
      " 66%|██████▋   | 327/493 [06:36<05:36,  2.02s/it]\u001b[A\n",
      " 67%|██████▋   | 328/493 [06:41<07:50,  2.85s/it]\u001b[A\n",
      " 67%|██████▋   | 329/493 [06:46<09:07,  3.34s/it]\u001b[A\n",
      " 67%|██████▋   | 330/493 [06:50<09:54,  3.65s/it]\u001b[A\n",
      " 67%|██████▋   | 331/493 [06:54<10:26,  3.87s/it]\u001b[A\n",
      " 67%|██████▋   | 332/493 [06:59<10:49,  4.03s/it]\u001b[A\n",
      " 68%|██████▊   | 333/493 [07:03<11:05,  4.16s/it]\u001b[A\n",
      " 68%|██████▊   | 334/493 [07:04<08:31,  3.22s/it]\u001b[A\n",
      " 68%|██████▊   | 335/493 [07:05<06:43,  2.55s/it]\u001b[A\n",
      " 68%|██████▊   | 336/493 [07:06<05:28,  2.09s/it]\u001b[A\n",
      " 68%|██████▊   | 337/493 [07:07<04:33,  1.76s/it]\u001b[A\n",
      " 69%|██████▊   | 338/493 [07:08<03:55,  1.52s/it]\u001b[A\n",
      " 69%|██████▉   | 339/493 [07:09<03:28,  1.36s/it]\u001b[A\n",
      " 69%|██████▉   | 340/493 [07:10<03:12,  1.26s/it]\u001b[A\n",
      " 69%|██████▉   | 341/493 [07:11<02:58,  1.18s/it]\u001b[A\n",
      " 69%|██████▉   | 342/493 [07:12<02:49,  1.12s/it]\u001b[A\n",
      " 70%|██████▉   | 343/493 [07:13<02:41,  1.08s/it]\u001b[A\n",
      " 70%|██████▉   | 344/493 [07:14<02:39,  1.07s/it]\u001b[A\n",
      " 70%|██████▉   | 345/493 [07:15<02:36,  1.05s/it]\u001b[A\n",
      " 70%|███████   | 346/493 [07:16<02:36,  1.06s/it]\u001b[A\n",
      " 70%|███████   | 347/493 [07:18<03:10,  1.31s/it]\u001b[A\n",
      " 71%|███████   | 348/493 [07:20<03:36,  1.50s/it]\u001b[A\n",
      " 71%|███████   | 349/493 [07:22<03:31,  1.47s/it]\u001b[A\n",
      " 71%|███████   | 350/493 [07:23<03:29,  1.47s/it]\u001b[A\n",
      " 71%|███████   | 351/493 [07:25<03:23,  1.44s/it]\u001b[A\n",
      " 71%|███████▏  | 352/493 [07:26<03:22,  1.43s/it]\u001b[A\n",
      " 72%|███████▏  | 353/493 [07:27<03:20,  1.43s/it]\u001b[A\n",
      " 72%|███████▏  | 354/493 [07:29<03:19,  1.43s/it]\u001b[A\n",
      " 72%|███████▏  | 355/493 [07:32<04:26,  1.93s/it]\u001b[A\n",
      " 72%|███████▏  | 356/493 [07:35<05:25,  2.37s/it]\u001b[A\n",
      " 72%|███████▏  | 357/493 [07:39<06:09,  2.72s/it]\u001b[A\n",
      " 73%|███████▎  | 358/493 [07:42<06:19,  2.81s/it]\u001b[A\n",
      " 73%|███████▎  | 359/493 [07:45<06:29,  2.91s/it]\u001b[A\n",
      " 73%|███████▎  | 360/493 [07:48<06:41,  3.02s/it]\u001b[A\n",
      " 73%|███████▎  | 361/493 [07:51<06:38,  3.02s/it]\u001b[A\n",
      " 73%|███████▎  | 362/493 [07:54<06:43,  3.08s/it]\u001b[A\n",
      " 74%|███████▎  | 363/493 [07:58<06:39,  3.07s/it]\u001b[A\n",
      " 74%|███████▍  | 364/493 [07:59<05:45,  2.68s/it]\u001b[A\n",
      " 74%|███████▍  | 365/493 [08:03<06:37,  3.10s/it]\u001b[A\n",
      " 74%|███████▍  | 366/493 [08:07<07:11,  3.40s/it]\u001b[A\n",
      " 74%|███████▍  | 367/493 [08:12<07:36,  3.62s/it]\u001b[A\n",
      " 75%|███████▍  | 368/493 [08:16<07:51,  3.77s/it]\u001b[A\n",
      " 75%|███████▍  | 369/493 [08:20<08:05,  3.91s/it]\u001b[A\n",
      " 75%|███████▌  | 370/493 [08:24<07:46,  3.79s/it]\u001b[A\n",
      " 75%|███████▌  | 371/493 [08:27<07:40,  3.77s/it]\u001b[A\n",
      " 75%|███████▌  | 372/493 [08:31<07:33,  3.75s/it]\u001b[A\n",
      " 76%|███████▌  | 373/493 [08:35<07:31,  3.76s/it]\u001b[A\n",
      " 76%|███████▌  | 374/493 [08:38<07:19,  3.69s/it]\u001b[A\n",
      " 76%|███████▌  | 375/493 [08:42<07:11,  3.66s/it]\u001b[A\n",
      " 76%|███████▋  | 376/493 [08:45<07:05,  3.64s/it]\u001b[A\n",
      " 76%|███████▋  | 377/493 [08:49<07:00,  3.62s/it]\u001b[A\n",
      " 77%|███████▋  | 378/493 [08:53<06:56,  3.63s/it]\u001b[A\n",
      " 77%|███████▋  | 379/493 [08:56<07:01,  3.69s/it]\u001b[A\n",
      " 77%|███████▋  | 380/493 [09:00<07:05,  3.76s/it]\u001b[A\n",
      " 77%|███████▋  | 381/493 [09:04<07:04,  3.79s/it]\u001b[A\n",
      " 77%|███████▋  | 382/493 [09:08<07:04,  3.82s/it]\u001b[A\n",
      " 78%|███████▊  | 383/493 [09:11<06:39,  3.64s/it]\u001b[A\n",
      " 78%|███████▊  | 384/493 [09:14<06:13,  3.43s/it]\u001b[A\n",
      " 78%|███████▊  | 385/493 [09:17<05:56,  3.30s/it]\u001b[A\n",
      " 78%|███████▊  | 386/493 [09:20<05:40,  3.18s/it]\u001b[A\n",
      " 78%|███████▊  | 387/493 [09:23<05:33,  3.15s/it]\u001b[A\n",
      " 79%|███████▊  | 388/493 [09:26<05:24,  3.09s/it]\u001b[A\n",
      " 79%|███████▉  | 389/493 [09:29<05:19,  3.07s/it]\u001b[A\n",
      " 79%|███████▉  | 390/493 [09:32<05:14,  3.06s/it]\u001b[A\n",
      " 79%|███████▉  | 391/493 [09:35<05:07,  3.01s/it]\u001b[A\n",
      " 80%|███████▉  | 392/493 [09:38<05:03,  3.01s/it]\u001b[A\n",
      " 80%|███████▉  | 393/493 [09:41<04:59,  3.00s/it]\u001b[A\n",
      " 80%|███████▉  | 394/493 [09:44<04:55,  2.98s/it]\u001b[A\n",
      " 80%|████████  | 395/493 [09:45<03:59,  2.45s/it]\u001b[A\n",
      " 80%|████████  | 396/493 [09:46<03:15,  2.02s/it]\u001b[A\n",
      " 81%|████████  | 397/493 [09:47<02:42,  1.70s/it]\u001b[A\n",
      " 81%|████████  | 398/493 [09:48<02:20,  1.48s/it]\u001b[A\n",
      " 81%|████████  | 399/493 [09:49<02:04,  1.32s/it]\u001b[A\n",
      " 81%|████████  | 400/493 [09:50<01:52,  1.21s/it]\u001b[A\n",
      " 81%|████████▏ | 401/493 [09:51<01:44,  1.13s/it]\u001b[A\n",
      " 82%|████████▏ | 402/493 [09:52<01:38,  1.08s/it]\u001b[A\n",
      " 82%|████████▏ | 403/493 [09:53<01:34,  1.05s/it]\u001b[A\n",
      " 82%|████████▏ | 404/493 [09:54<01:30,  1.02s/it]\u001b[A\n",
      " 82%|████████▏ | 405/493 [09:55<01:30,  1.03s/it]\u001b[A\n",
      " 82%|████████▏ | 406/493 [09:56<01:27,  1.01s/it]\u001b[A\n",
      " 83%|████████▎ | 407/493 [09:57<01:25,  1.01it/s]\u001b[A\n",
      " 83%|████████▎ | 408/493 [09:58<01:23,  1.02it/s]\u001b[A\n",
      " 83%|████████▎ | 409/493 [09:59<01:22,  1.02it/s]\u001b[A\n",
      " 83%|████████▎ | 410/493 [10:00<01:20,  1.03it/s]\u001b[A\n",
      " 83%|████████▎ | 411/493 [10:01<01:19,  1.03it/s]\u001b[A\n",
      " 84%|████████▎ | 412/493 [10:03<01:44,  1.29s/it]\u001b[A\n",
      " 84%|████████▍ | 413/493 [10:04<01:33,  1.17s/it]\u001b[A\n",
      " 84%|████████▍ | 414/493 [10:05<01:25,  1.08s/it]\u001b[A\n",
      " 84%|████████▍ | 415/493 [10:05<01:19,  1.02s/it]\u001b[A\n",
      " 84%|████████▍ | 416/493 [10:06<01:15,  1.03it/s]\u001b[A\n",
      " 85%|████████▍ | 417/493 [10:07<01:11,  1.07it/s]\u001b[A\n",
      " 85%|████████▍ | 418/493 [10:08<01:08,  1.09it/s]\u001b[A\n",
      " 85%|████████▍ | 419/493 [10:09<01:07,  1.09it/s]\u001b[A\n",
      " 85%|████████▌ | 420/493 [10:12<01:44,  1.44s/it]\u001b[A\n",
      " 85%|████████▌ | 421/493 [10:14<02:09,  1.80s/it]\u001b[A\n",
      " 86%|████████▌ | 422/493 [10:17<02:23,  2.03s/it]\u001b[A\n",
      " 86%|████████▌ | 423/493 [10:19<02:34,  2.20s/it]\u001b[A\n",
      " 86%|████████▌ | 424/493 [10:22<02:42,  2.35s/it]\u001b[A\n",
      " 86%|████████▌ | 425/493 [10:25<02:47,  2.46s/it]\u001b[A\n",
      " 86%|████████▋ | 426/493 [10:28<02:50,  2.55s/it]\u001b[A\n",
      " 87%|████████▋ | 427/493 [10:30<02:48,  2.56s/it]\u001b[A\n",
      " 87%|████████▋ | 428/493 [10:33<02:48,  2.58s/it]\u001b[A\n",
      " 87%|████████▋ | 429/493 [10:36<02:53,  2.71s/it]\u001b[A\n",
      " 87%|████████▋ | 430/493 [10:39<02:57,  2.82s/it]\u001b[A\n",
      " 87%|████████▋ | 431/493 [10:42<03:01,  2.93s/it]\u001b[A\n",
      " 88%|████████▊ | 432/493 [10:45<03:02,  2.99s/it]\u001b[A\n",
      " 88%|████████▊ | 433/493 [10:48<03:02,  3.05s/it]\u001b[A\n",
      " 88%|████████▊ | 434/493 [10:52<03:01,  3.07s/it]\u001b[A\n",
      " 88%|████████▊ | 435/493 [10:55<03:03,  3.16s/it]\u001b[A\n",
      " 88%|████████▊ | 436/493 [10:58<03:03,  3.23s/it]\u001b[A\n",
      " 89%|████████▊ | 437/493 [11:01<02:58,  3.19s/it]\u001b[A\n",
      " 89%|████████▉ | 438/493 [11:05<02:53,  3.16s/it]\u001b[A\n",
      " 89%|████████▉ | 439/493 [11:08<02:50,  3.15s/it]\u001b[A\n",
      " 89%|████████▉ | 440/493 [11:11<02:48,  3.17s/it]\u001b[A\n",
      " 89%|████████▉ | 441/493 [11:14<02:48,  3.23s/it]\u001b[A\n",
      " 90%|████████▉ | 442/493 [11:17<02:43,  3.21s/it]\u001b[A\n",
      " 90%|████████▉ | 443/493 [11:21<02:40,  3.21s/it]\u001b[A\n",
      " 90%|█████████ | 444/493 [11:24<02:37,  3.21s/it]\u001b[A\n",
      " 90%|█████████ | 445/493 [11:27<02:34,  3.22s/it]\u001b[A\n",
      " 90%|█████████ | 446/493 [11:30<02:32,  3.24s/it]\u001b[A\n",
      " 91%|█████████ | 447/493 [11:34<02:28,  3.23s/it]\u001b[A\n",
      " 91%|█████████ | 448/493 [11:37<02:24,  3.22s/it]\u001b[A\n",
      " 91%|█████████ | 449/493 [11:40<02:23,  3.27s/it]\u001b[A\n",
      " 91%|█████████▏| 450/493 [11:43<02:19,  3.24s/it]\u001b[A\n",
      " 91%|█████████▏| 451/493 [11:47<02:16,  3.26s/it]\u001b[A\n",
      " 92%|█████████▏| 452/493 [11:50<02:13,  3.27s/it]\u001b[A\n",
      " 92%|█████████▏| 453/493 [11:53<02:11,  3.28s/it]\u001b[A\n",
      " 92%|█████████▏| 454/493 [11:57<02:08,  3.30s/it]\u001b[A\n",
      " 92%|█████████▏| 455/493 [12:00<02:04,  3.28s/it]\u001b[A\n",
      " 92%|█████████▏| 456/493 [12:02<01:47,  2.91s/it]\u001b[A\n",
      " 93%|█████████▎| 457/493 [12:04<01:35,  2.67s/it]\u001b[A\n",
      " 93%|█████████▎| 458/493 [12:06<01:27,  2.51s/it]\u001b[A\n",
      " 93%|█████████▎| 459/493 [12:08<01:20,  2.37s/it]\u001b[A\n",
      " 93%|█████████▎| 460/493 [12:10<01:15,  2.29s/it]\u001b[A\n",
      " 94%|█████████▎| 461/493 [12:12<01:11,  2.22s/it]\u001b[A\n",
      " 94%|█████████▎| 462/493 [12:14<01:07,  2.18s/it]\u001b[A\n",
      " 94%|█████████▍| 463/493 [12:16<01:04,  2.15s/it]\u001b[A\n",
      " 94%|█████████▍| 464/493 [12:18<01:01,  2.12s/it]\u001b[A\n",
      " 94%|█████████▍| 465/493 [12:21<00:58,  2.10s/it]\u001b[A\n",
      " 95%|█████████▍| 466/493 [12:22<00:54,  2.01s/it]\u001b[A\n",
      " 95%|█████████▍| 467/493 [12:24<00:51,  1.99s/it]\u001b[A\n",
      " 95%|█████████▍| 468/493 [12:26<00:48,  1.95s/it]\u001b[A\n",
      " 95%|█████████▌| 469/493 [12:28<00:45,  1.92s/it]\u001b[A\n",
      " 95%|█████████▌| 470/493 [12:30<00:44,  1.92s/it]\u001b[A\n",
      " 96%|█████████▌| 471/493 [12:32<00:42,  1.92s/it]\u001b[A\n",
      " 96%|█████████▌| 472/493 [12:33<00:36,  1.72s/it]\u001b[A\n",
      " 96%|█████████▌| 473/493 [12:34<00:32,  1.61s/it]\u001b[A\n",
      " 96%|█████████▌| 474/493 [12:36<00:28,  1.51s/it]\u001b[A\n",
      " 96%|█████████▋| 475/493 [12:37<00:25,  1.43s/it]\u001b[A\n",
      " 97%|█████████▋| 476/493 [12:38<00:23,  1.37s/it]\u001b[A\n",
      " 97%|█████████▋| 477/493 [12:39<00:20,  1.30s/it]\u001b[A\n",
      " 97%|█████████▋| 478/493 [12:41<00:19,  1.28s/it]\u001b[A\n",
      " 97%|█████████▋| 479/493 [12:42<00:17,  1.25s/it]\u001b[A\n",
      " 97%|█████████▋| 480/493 [12:43<00:16,  1.24s/it]\u001b[A\n",
      " 98%|█████████▊| 481/493 [12:44<00:14,  1.25s/it]\u001b[A\n",
      " 98%|█████████▊| 482/493 [12:45<00:13,  1.22s/it]\u001b[A\n",
      " 98%|█████████▊| 483/493 [12:47<00:12,  1.21s/it]\u001b[A\n",
      " 98%|█████████▊| 484/493 [12:48<00:11,  1.28s/it]\u001b[A\n",
      " 98%|█████████▊| 485/493 [12:49<00:10,  1.32s/it]\u001b[A\n",
      " 99%|█████████▊| 486/493 [12:51<00:09,  1.36s/it]\u001b[A\n",
      " 99%|█████████▉| 487/493 [12:52<00:08,  1.38s/it]\u001b[A\n",
      " 99%|█████████▉| 488/493 [12:54<00:07,  1.40s/it]\u001b[A\n",
      " 99%|█████████▉| 489/493 [12:55<00:05,  1.41s/it]\u001b[A\n",
      " 99%|█████████▉| 490/493 [12:57<00:04,  1.40s/it]\u001b[A\n",
      "100%|█████████▉| 491/493 [12:58<00:02,  1.41s/it]\u001b[A\n",
      "100%|█████████▉| 492/493 [12:59<00:01,  1.39s/it]\u001b[A\n",
      "100%|██████████| 493/493 [13:01<00:00,  1.58s/it]\u001b[A\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data size      (493, 14)\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[100]\tvalid_0's l2: 2.91938e+10\tvalid_0's mse_score: 2.91938e+10\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's l2: 4.05356e+10\tvalid_0's mse_score: 4.05356e+10\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[100]\tvalid_0's l2: 2.21098e+10\tvalid_0's mse_score: 2.21098e+10\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's l2: 2.81309e+10\tvalid_0's mse_score: 2.81309e+10\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[100]\tvalid_0's l2: 1.65064e+10\tvalid_0's mse_score: 1.65064e+10\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's l2: 2.30566e+10\tvalid_0's mse_score: 2.30566e+10\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[100]\tvalid_0's l2: 3.70353e+10\tvalid_0's mse_score: 3.70353e+10\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's l2: 4.6812e+10\tvalid_0's mse_score: 4.6812e+10\n",
      "Training until validation scores don't improve for 100 rounds\n",
      "[100]\tvalid_0's l2: 6.28107e+09\tvalid_0's mse_score: 6.28107e+09\n",
      "Early stopping, best iteration is:\n",
      "[1]\tvalid_0's l2: 9.68204e+09\tvalid_0's mse_score: 9.68204e+09\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  5%|▍         | 1/22 [14:19<5:00:54, 859.73s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "++++++++++++++++++\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "  0%|          | 0/7577 [00:00<?, ?it/s]\u001b[A"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CNSHK-MYTPP (7577,)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "  0%|          | 1/7577 [00:04<9:56:36,  4.72s/it]\u001b[A\n",
      "  0%|          | 2/7577 [00:08<9:38:20,  4.58s/it]\u001b[A\n",
      "  0%|          | 3/7577 [00:13<9:32:35,  4.54s/it]\u001b[A\n",
      "  0%|          | 4/7577 [00:17<9:32:37,  4.54s/it]\u001b[A\n",
      "  0%|          | 5/7577 [00:22<9:34:21,  4.55s/it]\u001b[A\n",
      "  0%|          | 6/7577 [00:26<9:30:41,  4.52s/it]\u001b[A\n",
      "  0%|          | 7/7577 [00:31<9:27:49,  4.50s/it]\u001b[A\n",
      "  0%|          | 8/7577 [00:35<9:24:31,  4.47s/it]\u001b[A\n",
      "  0%|          | 9/7577 [00:40<9:17:07,  4.42s/it]\u001b[A\n",
      "  0%|          | 10/7577 [00:44<9:09:17,  4.36s/it]\u001b[A\n",
      "  0%|          | 11/7577 [00:48<9:03:21,  4.31s/it]\u001b[A\n",
      "  0%|          | 12/7577 [00:54<9:47:18,  4.66s/it]\u001b[A\n",
      "  0%|          | 13/7577 [00:58<9:33:35,  4.55s/it]\u001b[A\n",
      "  0%|          | 14/7577 [01:02<9:20:54,  4.45s/it]\u001b[A\n",
      "  0%|          | 15/7577 [01:06<9:15:45,  4.41s/it]\u001b[A\n",
      "  0%|          | 16/7577 [01:11<9:08:05,  4.35s/it]\u001b[A\n",
      "  0%|          | 17/7577 [01:15<9:12:14,  4.38s/it]\u001b[A\n",
      "  0%|          | 18/7577 [01:19<9:15:11,  4.41s/it]\u001b[A\n",
      "  0%|          | 19/7577 [01:24<9:11:01,  4.37s/it]\u001b[A\n",
      "  0%|          | 20/7577 [01:28<9:08:39,  4.36s/it]\u001b[A\n",
      "  0%|          | 21/7577 [01:32<9:04:24,  4.32s/it]\u001b[A\n",
      "  0%|          | 22/7577 [01:37<9:00:07,  4.29s/it]\u001b[A\n",
      "  0%|          | 23/7577 [01:41<8:56:51,  4.26s/it]\u001b[A\n",
      "  0%|          | 24/7577 [01:45<8:56:45,  4.26s/it]\u001b[A\n",
      "  0%|          | 25/7577 [01:50<9:20:36,  4.45s/it]\u001b[A\n",
      "  0%|          | 26/7577 [01:54<9:12:02,  4.39s/it]\u001b[A\n",
      "  0%|          | 27/7577 [01:58<9:05:58,  4.34s/it]\u001b[A\n",
      "  0%|          | 28/7577 [02:03<9:07:34,  4.35s/it]\u001b[A\n",
      "  0%|          | 29/7577 [02:07<9:06:02,  4.34s/it]\u001b[A\n",
      "  0%|          | 30/7577 [02:11<9:00:39,  4.30s/it]\u001b[A\n",
      "  0%|          | 31/7577 [02:16<9:06:57,  4.35s/it]\u001b[A\n",
      "  0%|          | 32/7577 [02:20<9:10:53,  4.38s/it]\u001b[A\n",
      "  0%|          | 33/7577 [02:24<9:07:26,  4.35s/it]\u001b[A\n",
      "  0%|          | 34/7577 [02:29<9:03:08,  4.32s/it]\u001b[A\n",
      "  0%|          | 35/7577 [02:33<9:01:11,  4.31s/it]\u001b[A\n",
      "  0%|          | 36/7577 [02:37<8:57:37,  4.28s/it]\u001b[A\n",
      "  0%|          | 37/7577 [02:41<8:55:58,  4.27s/it]\u001b[A\n",
      "  1%|          | 38/7577 [02:46<8:54:34,  4.25s/it]\u001b[A\n",
      "  1%|          | 39/7577 [02:50<8:55:26,  4.26s/it]\u001b[A\n",
      "  1%|          | 40/7577 [02:54<8:53:46,  4.25s/it]\u001b[A\n",
      "  1%|          | 41/7577 [02:58<8:53:38,  4.25s/it]\u001b[A\n",
      "  1%|          | 42/7577 [03:03<8:54:50,  4.26s/it]\u001b[A\n",
      "  1%|          | 43/7577 [03:07<8:55:24,  4.26s/it]\u001b[A\n",
      "  1%|          | 44/7577 [03:12<9:06:10,  4.35s/it]\u001b[A\n",
      "  1%|          | 45/7577 [03:17<9:36:58,  4.60s/it]\u001b[A\n",
      "  1%|          | 46/7577 [03:22<9:56:42,  4.75s/it]\u001b[A\n",
      "  1%|          | 47/7577 [03:27<10:05:43,  4.83s/it]\u001b[A\n",
      "  1%|          | 48/7577 [03:32<10:13:15,  4.89s/it]\u001b[A\n",
      "  1%|          | 49/7577 [03:37<10:21:02,  4.95s/it]\u001b[A\n",
      "  1%|          | 50/7577 [03:42<10:22:54,  4.97s/it]\u001b[A\n",
      "  1%|          | 51/7577 [03:47<10:24:07,  4.98s/it]\u001b[A\n",
      "  1%|          | 52/7577 [03:52<10:27:47,  5.01s/it]\u001b[A\n",
      "  1%|          | 53/7577 [03:56<9:57:38,  4.77s/it] \u001b[A\n",
      "  1%|          | 54/7577 [04:00<9:36:00,  4.59s/it]\u001b[A\n",
      "  1%|          | 55/7577 [04:05<9:25:45,  4.51s/it]\u001b[A\n",
      "  1%|          | 56/7577 [04:09<9:30:47,  4.55s/it]\u001b[A\n",
      "  1%|          | 57/7577 [04:14<9:25:19,  4.51s/it]\u001b[A\n",
      "  1%|          | 58/7577 [04:18<9:17:41,  4.45s/it]\u001b[A\n",
      "  1%|          | 59/7577 [04:22<9:11:47,  4.40s/it]\u001b[A\n",
      "  1%|          | 60/7577 [04:27<9:07:45,  4.37s/it]\u001b[A\n",
      "  1%|          | 61/7577 [04:31<9:01:28,  4.32s/it]\u001b[A\n",
      "  1%|          | 62/7577 [04:35<8:56:24,  4.28s/it]\u001b[A\n",
      "  1%|          | 63/7577 [04:39<8:55:59,  4.28s/it]\u001b[A\n",
      "  1%|          | 64/7577 [04:44<8:56:57,  4.29s/it]\u001b[A\n",
      "  1%|          | 65/7577 [04:48<8:56:17,  4.28s/it]\u001b[A\n",
      "  1%|          | 66/7577 [04:52<8:58:30,  4.30s/it]\u001b[A\n",
      "  1%|          | 67/7577 [04:57<8:59:35,  4.31s/it]\u001b[A\n",
      "  1%|          | 68/7577 [05:01<8:56:34,  4.29s/it]\u001b[A\n",
      "  1%|          | 69/7577 [05:05<8:53:24,  4.26s/it]\u001b[A\n",
      "  1%|          | 70/7577 [05:09<8:51:20,  4.25s/it]\u001b[A\n",
      "  1%|          | 71/7577 [05:14<8:59:54,  4.32s/it]\u001b[A\n",
      "  1%|          | 72/7577 [05:18<9:01:17,  4.33s/it]\u001b[A\n",
      "  1%|          | 73/7577 [05:22<9:00:07,  4.32s/it]\u001b[A\n",
      "  1%|          | 74/7577 [05:27<9:00:02,  4.32s/it]\u001b[A\n",
      "  1%|          | 75/7577 [05:32<9:24:21,  4.51s/it]\u001b[A\n",
      "  1%|          | 76/7577 [05:37<9:37:43,  4.62s/it]\u001b[A\n",
      "  1%|          | 77/7577 [05:41<9:40:30,  4.64s/it]\u001b[A\n",
      "  1%|          | 78/7577 [05:46<9:32:33,  4.58s/it]\u001b[A\n",
      "  1%|          | 79/7577 [05:50<9:23:25,  4.51s/it]\u001b[A\n",
      "  1%|          | 80/7577 [05:54<9:15:39,  4.45s/it]\u001b[A\n",
      "  1%|          | 81/7577 [05:59<9:11:23,  4.41s/it]\u001b[A\n",
      "  1%|          | 82/7577 [06:03<9:04:39,  4.36s/it]\u001b[A\n",
      "  1%|          | 83/7577 [06:07<9:02:27,  4.34s/it]\u001b[A\n",
      "  1%|          | 84/7577 [06:12<9:00:24,  4.33s/it]\u001b[A\n",
      "  1%|          | 85/7577 [06:16<9:01:18,  4.34s/it]\u001b[A\n",
      "  1%|          | 86/7577 [06:20<8:56:44,  4.30s/it]\u001b[A\n",
      "  1%|          | 87/7577 [06:24<8:55:38,  4.29s/it]\u001b[A\n",
      "  1%|          | 88/7577 [06:29<9:19:24,  4.48s/it]\u001b[A\n",
      "  1%|          | 89/7577 [06:34<9:39:14,  4.64s/it]\u001b[A\n",
      "  1%|          | 90/7577 [06:39<9:50:27,  4.73s/it]\u001b[A\n",
      "  1%|          | 91/7577 [06:44<9:58:20,  4.80s/it]\u001b[A\n",
      "  1%|          | 92/7577 [06:49<10:04:13,  4.84s/it]\u001b[A\n",
      "  1%|          | 93/7577 [06:53<9:42:46,  4.67s/it] \u001b[A\n",
      "  1%|          | 94/7577 [06:58<9:29:03,  4.56s/it]\u001b[A\n",
      "  1%|▏         | 95/7577 [07:02<9:15:14,  4.45s/it]\u001b[A\n",
      "  1%|▏         | 96/7577 [07:06<9:08:10,  4.40s/it]\u001b[A\n",
      "  1%|▏         | 97/7577 [07:10<9:00:40,  4.34s/it]\u001b[A\n",
      "  1%|▏         | 98/7577 [07:15<8:55:30,  4.30s/it]\u001b[A\n",
      "  1%|▏         | 99/7577 [07:19<8:52:10,  4.27s/it]\u001b[A\n",
      "  1%|▏         | 100/7577 [07:23<8:51:18,  4.26s/it]\u001b[A\n",
      "  1%|▏         | 101/7577 [07:27<8:48:30,  4.24s/it]\u001b[A\n",
      "  1%|▏         | 102/7577 [07:31<8:45:58,  4.22s/it]\u001b[A\n",
      "  1%|▏         | 103/7577 [07:36<8:47:28,  4.23s/it]\u001b[A\n",
      "  1%|▏         | 104/7577 [07:40<8:45:28,  4.22s/it]\u001b[A\n",
      "  1%|▏         | 105/7577 [07:44<8:43:51,  4.21s/it]\u001b[A\n",
      "  1%|▏         | 106/7577 [07:48<8:42:58,  4.20s/it]\u001b[A\n",
      "  1%|▏         | 107/7577 [07:54<9:26:06,  4.55s/it]\u001b[A\n",
      "  1%|▏         | 108/7577 [07:58<9:30:45,  4.58s/it]\u001b[A\n",
      "  1%|▏         | 109/7577 [08:03<9:29:30,  4.58s/it]\u001b[A\n",
      "  1%|▏         | 110/7577 [08:07<9:29:01,  4.57s/it]\u001b[A\n",
      "  1%|▏         | 111/7577 [08:12<9:18:05,  4.49s/it]\u001b[A\n",
      "  1%|▏         | 112/7577 [08:16<9:16:07,  4.47s/it]\u001b[A\n",
      "  1%|▏         | 113/7577 [08:21<9:16:14,  4.47s/it]\u001b[A\n",
      "  2%|▏         | 114/7577 [08:25<9:11:01,  4.43s/it]\u001b[A\n",
      "  2%|▏         | 115/7577 [08:29<9:10:05,  4.42s/it]\u001b[A\n",
      "  2%|▏         | 116/7577 [08:34<9:07:58,  4.41s/it]\u001b[A\n",
      "  2%|▏         | 117/7577 [08:38<9:06:16,  4.39s/it]\u001b[A\n",
      "  2%|▏         | 118/7577 [08:42<9:07:20,  4.40s/it]\u001b[A\n",
      "  2%|▏         | 119/7577 [08:47<9:12:40,  4.45s/it]\u001b[A\n",
      "  2%|▏         | 120/7577 [08:52<9:52:00,  4.76s/it]\u001b[A\n",
      "  2%|▏         | 121/7577 [08:57<9:41:46,  4.68s/it]\u001b[A\n",
      "  2%|▏         | 122/7577 [09:01<9:30:10,  4.59s/it]\u001b[A\n",
      "  2%|▏         | 123/7577 [09:06<9:18:51,  4.50s/it]\u001b[A\n",
      "  2%|▏         | 124/7577 [09:10<9:12:04,  4.44s/it]\u001b[A\n",
      "  2%|▏         | 125/7577 [09:14<9:08:43,  4.42s/it]\u001b[A\n",
      "  2%|▏         | 126/7577 [09:19<9:03:27,  4.38s/it]\u001b[A\n",
      "  2%|▏         | 127/7577 [09:27<9:15:18,  4.47s/it]\u001b[A\n",
      "  5%|▍         | 1/22 [29:46<10:25:14, 1786.40s/it]\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-14-536614f732b5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m     \u001b[0mroute_order_info\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_train_route_order_data\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroute\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'++++++++++++++++++'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m     \u001b[0mtrain_data\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mget_train_data\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroute_order_info\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mroute\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0mfeatures\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mc\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mc\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mtrain_data\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mc\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32min\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;34m'loadingOrder'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'label'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'carrierName'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'vesselMMSI'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'direction'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'TRANSPORT_TRACE'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[0mmodel_by_route\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtrain_model\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtrain_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mfeatures\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtrain_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'label'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-13-8c1a3d570623>\u001b[0m in \u001b[0;36mget_train_data\u001b[1;34m(route_order_info, route)\u001b[0m\n\u001b[0;32m     11\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mroute\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0morder_list\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     12\u001b[0m     \u001b[1;32mfor\u001b[0m \u001b[0morder\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mtqdm\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0morder_list\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m         \u001b[0morder_info_set\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mroute_order_info\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mroute_order_info\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'loadingOrder'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0morder\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msort_values\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mby\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'timestamp'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreset_index\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdrop\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     14\u001b[0m \u001b[1;31m#         print(order_info_set)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     15\u001b[0m \u001b[1;31m#       获取起航时间\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\Program\\Anaconda\\envs\\AI\\lib\\site-packages\\pandas\\core\\ops\\__init__.py\u001b[0m in \u001b[0;36mwrapper\u001b[1;34m(self, other, axis)\u001b[0m\n\u001b[0;32m   1227\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1228\u001b[0m             \u001b[1;32mwith\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merrstate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mall\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"ignore\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1229\u001b[1;33m                 \u001b[0mres\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mna_op\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1230\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_scalar\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mres\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1231\u001b[0m                 raise TypeError(\n",
      "\u001b[1;32mD:\\Program\\Anaconda\\envs\\AI\\lib\\site-packages\\pandas\\core\\ops\\__init__.py\u001b[0m in \u001b[0;36mna_op\u001b[1;34m(x, y)\u001b[0m\n\u001b[0;32m   1089\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1090\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mis_object_dtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdtype\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1091\u001b[1;33m             \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_comp_method_OBJECT_ARRAY\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mop\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1092\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1093\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0mis_datetimelike_v_numeric\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "for route in tqdm(test_order_belong_to_trace):\n",
    "    route_order_info = get_train_route_order_data(route)\n",
    "    print('++++++++++++++++++')\n",
    "    train_data = get_train_data(route_order_info, route)\n",
    "    features = [c for c in train_data.columns if c not in ['loadingOrder', 'label', 'carrierName', 'vesselMMSI', 'direction', 'TRANSPORT_TRACE']]\n",
    "    model_by_route = train_model(train_data[features], train_data['label'])\n",
    "    \n",
    "    for order in test_order_belong_to_trace[route]:\n",
    "        test_order_data = get_test_data(order)\n",
    "        res = model_by_route.predict(test_order_data[features], num_iteration=model_by_route.best_iteration)\n",
    "        test_data_origin.loc[test_data_origin['loadingOrder'] == order, 'ETA'] = (test_data_origin[test_data_origin['loadingOrder'] == order]['onboardDate'] + pd.Timedelta(seconds=res[0])).apply(lambda x:x.strftime('%Y/%m/%d  %H:%M:%S'))\n",
    "    \n",
    "test_data_origin['creatDate'] = pd.datetime.now().strftime('%Y/%m/%d  %H:%M:%S')\n",
    "test_data_origin['timestamp'] = test_data_origin['temp_timestamp']\n",
    "\n",
    "result = test_data_origin[['loadingOrder', 'timestamp', 'longitude', 'latitude', 'carrierName', 'vesselMMSI', 'onboardDate', 'ETA', 'creatDate']]\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "result.to_csv(result_path, index=False)\n",
    "mox.file.copy_parallel(result_path, OBS_RES_PATH)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.6 64-bit ('AI': conda)",
   "language": "python",
   "name": "python37664bitaiconda6859e03b37c34f0182c9bde8073269f7"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
